package site.reg

//import site.addzero.addl.intention.RemoveShitCodeIntention
import com.intellij.codeInsight.intention.IntentionManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.startup.ProjectActivity
import site.addzero.addl.action.dictgen.intention.GenEnumByFieldCommentIntention
import site.addzero.addl.intention.custom.AddCusTomAnnotationAction
import site.addzero.addl.intention.custom.AddCusTomAnnotationJavaAction
import site.addzero.addl.intention.excel.AddExcelPropertyAnnotationAction
import site.addzero.addl.intention.excel.AddExcelPropertyAnnotationJavaAction


class AddActionAndIntentions : ProjectActivity {
//    override fun runActivity(project: Project) {
//    }

    override suspend fun execute(project: Project) {

//        val intentionBaseClass = JavaPsiFacade.getInstance(project)
//            .findClass("com.intellij.codeInsight.intention.IntentionAction", GlobalSearchScope.allScope(project))
//        intentionBaseClass ?: return
//        val toList =
//            ClassInheritorsSearch.search(intentionBaseClass, ProjectScope.getContentScope(project), false, false, false)
//                .toList()
//        println()



        registerIntentions()
//        registerActions()

    }

}

private fun registerIntentions() {
    // 在插件启动时注册所有意图动作
    val intentionManager = IntentionManager.getInstance()


    //注册java意图
    intentionManager.addAction(AddExcelPropertyAnnotationJavaAction())
    intentionManager.addAction(AddCusTomAnnotationJavaAction())
    intentionManager.addAction(GenEnumByFieldCommentIntention())


    //注册kt意图
    intentionManager.addAction(AddExcelPropertyAnnotationAction())
    intentionManager.addAction(AddCusTomAnnotationAction())
//    intentionManager.addAction(ConvertToVersionCatalogIntention())

//    intentionManager.addAction(RemoveShitCodeIntention())
//    intentionManager.addAction(KotlinLambdaIntentionAction())


//    intentionManager.addAction(GenEnumByFieldCommentIntention())
}


//fun registerActions() {
//    val actionManager = ActionManager.getInstance()
//
//    // 注册主菜单
//    val autoDDLAction = AutoDDL()
//    actionManager.registerAction("AutoDDL", autoDDLAction)
//    actionManager.getAction("ToolsMenu")?.let { toolsMenu ->
//        if (toolsMenu is DefaultActionGroup) {
//            toolsMenu.addAction(autoDDLAction, com.intellij.openapi.actionSystem.Constraints.FIRST)
//        }
//    }
//
//    // 注册生成菜单组
//    val generateGroup = DefaultActionGroup("AutoDDL.GenerateGroup", true)
//
//
//    actionManager.registerAction("AutoDDL.GenerateGroup", generateGroup)
//    actionManager.getAction("GenerateGroup")?.let { genGroup ->
//        if (genGroup is DefaultActionGroup) {
//            genGroup.addAction(generateGroup, com.intellij.openapi.actionSystem.Constraints.FIRST)
//        }
//    }
//
//    // 添加生成菜单组的子Action
//    generateGroup.apply {
//        add(GenDDL())
//        add(GenJimmerDTO())
//        add(GenController())
//        add(GenExcelDTO())
//    }
//}
